//
//  ImageLayerView.swift
//  eBooks
//
//  Created by JunMing on 2019/11/7.
//  Copyright © 2019 赵俊明. All rights reserved.
//

import UIKit

class ImageLayerView: UIView {

    private var imageView = UIImageView()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        layer.shadowColor = UIColor.black.cgColor
        layer.shadowOffset = CGSize(width: 0, height: 0)
        layer.shadowOpacity = 0.6
        layer.shadowRadius = 3.0
        
        imageView.contentMode = .scaleAspectFill
        imageView.clipsToBounds = true;
        addSubview(imageView)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func loadImage(url:String?) {
        if let urlStr = url,let Url = URL(string: urlStr) {
            imageView.setImageWith(Url, placeholder: UIImage(named: "leamonReader"))
        }
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        imageView.frame = self.bounds
    }
}
